//
//  ClientInfo.swift
//
//  Created by 邱仙凯 on 2022/4/8
//  Copyright (c) . All rights reserved.
//

import Foundation
import ObjectMapper

public struct ClientInfo: Mappable {

  // MARK: Declaration for string constants to be used to decode and also serialize.
  private struct SerializationKeys {
    static let city = "city"
    static let zStaffNm = "z_staff_nm"
    static let clientId = "client_id"
    static let address = "address"
    static let zCreateTm = "z_create_tm"
    static let province = "province"
    static let clientDesc = "client_desc"
    static let zStaffId = "z_staff_id"
    static let orgCode = "org_code"
    static let orgName = "org_name"
    static let idKey = "id_key"
    static let clientName = "client_name"
    static let zJpId = "z_jp_id"
    static let tel = "tel"
  }

  // MARK: Properties
  public var city: String?
  public var zStaffNm: String?
  public var clientId: Int?
  public var address: String?
  public var zCreateTm: String?
  public var province: String?
  public var clientDesc: String?
  public var zStaffId: Int?
  public var orgCode: Int?
  public var orgName: String?
  public var idKey: String?
  public var clientName: String?
  public var zJpId: Int?
  public var tel: String?
    public var openx = true

  // MARK: ObjectMapper Initializers
  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public init?(map: Map){

  }

  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public mutating func mapping(map: Map) {
    city <- map[SerializationKeys.city]
    zStaffNm <- map[SerializationKeys.zStaffNm]
    clientId <- map[SerializationKeys.clientId]
    address <- map[SerializationKeys.address]
    zCreateTm <- map[SerializationKeys.zCreateTm]
    province <- map[SerializationKeys.province]
    clientDesc <- map[SerializationKeys.clientDesc]
    zStaffId <- map[SerializationKeys.zStaffId]
    orgCode <- map[SerializationKeys.orgCode]
    orgName <- map[SerializationKeys.orgName]
    idKey <- (map[SerializationKeys.idKey],StringTransform())
    clientName <- map[SerializationKeys.clientName]
    zJpId <- map[SerializationKeys.zJpId]
    tel <- map[SerializationKeys.tel]
  }

  /// Generates description of the object in the form of a NSDictionary.
  ///
  /// - returns: A Key value pair containing all valid values in the object.
  public func dictionaryRepresentation() -> [String: Any] {
    var dictionary: [String: Any] = [:]
    if let value = city { dictionary[SerializationKeys.city] = value }
    if let value = zStaffNm { dictionary[SerializationKeys.zStaffNm] = value }
    if let value = clientId { dictionary[SerializationKeys.clientId] = value }
    if let value = address { dictionary[SerializationKeys.address] = value }
    if let value = zCreateTm { dictionary[SerializationKeys.zCreateTm] = value }
    if let value = province { dictionary[SerializationKeys.province] = value }
    if let value = clientDesc { dictionary[SerializationKeys.clientDesc] = value }
    if let value = zStaffId { dictionary[SerializationKeys.zStaffId] = value }
    if let value = orgCode { dictionary[SerializationKeys.orgCode] = value }
    if let value = orgName { dictionary[SerializationKeys.orgName] = value }
      if let value = idKey { dictionary[SerializationKeys.idKey] = value } else {
          dictionary[SerializationKeys.idKey] = ""
      }
    if let value = clientName { dictionary[SerializationKeys.clientName] = value }
    if let value = zJpId { dictionary[SerializationKeys.zJpId] = value }
    if let value = tel { dictionary[SerializationKeys.tel] = value }
    return dictionary
  }

}
